import { isH5, isMpAlipay, isMpWeixin } from '@/utils/platform';
const app = getApp()
export default {
  data() {
    return {
      barHeight: 48,
      headHt: 48,
      menuBottom: 15,
    }
  },
  onLoad() {
    this.computeBarHt();
    setTimeout(() => {
      this.computeBarHt();
    }, 1000)
  },
  methods: {
    computeBarHt() {
      let headHt;
      let menuHeight = this.barHeight;
      if (isMpWeixin || isMpAlipay) {
        const rect = uni.getMenuButtonBoundingClientRect();
        if (rect) {
          menuHeight = rect.height;
          headHt = rect.top + menuHeight + this.menuBottom
          console.log('headHt == ', headHt);
        }
      } else {
        let systemInfo = uni.getSystemInfoSync();
        let statusBarHt = systemInfo.statusBarHeight || 20;

        if (isH5 && (window.app_origin == 'miniProj' || app?.globalData?.origin == 'miniProj')) {
          statusBarHt = 0;
        }
        
        headHt = statusBarHt + menuHeight + this.menuBottom;
      }
      // this.$showToast(this.menuBottom + '--headHt new >> > ' + String(headHt) )
      this.setData({
        barHeight: menuHeight,
        headHt: headHt + 'px'
      })
    }
  }
}